from django.db import models

# Create your models here.
class Author(models.Model):
        name = models.CharField(max_length=50)

        class Meta:
                ordering = ('name',)

        def __unicode__(self):
                return self.name

class Book(models.Model):
        name = models.CharField("Django Book",max_length=100)
        authors = models.ManyToManyField(Author)
        publishers = models.CharField(max_length=50)
        image = models.ImageField(upload_to='images')
        date_of_release = models.DateField()
        is_available = models.BooleanField(default=True)

        class Meta:
                ordering = ('date_of_release',)

        def __unicode__(self):
                return "%s published by %s" %(self.name, self.publishers)
